package ai.people.netmon.telegram.controller;

import ai.people.netmon.framework.domain.searchmsg.request.MessageRequest;
import ai.people.netmon.framework.domain.telegram.vo.channels.ChatMessage;
import ai.people.netmon.framework.model.request.PageKeyWordsRequest;
import ai.people.netmon.framework.model.response.PageResponse;
import ai.people.netmon.framework.model.response.ResponseResult;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.netmon.telegram.service.MessagesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 消息相关
 *
 * @author xing.wei
 * @description: 控制层
 * @date 2022/01/27
 * @since 2022-01-06 17:10:52
 */
@Slf4j
@RestController
@RequestMapping("/messages")
public class MessagesController {

    @Autowired
    private MessagesService messagesServiceImpl;


    /**
     * 分页查询信息列表
     *
     * @param pageKeyWordsRequest 页面关键字请求
     * @return {@link Result}<{@link PageResponse}<{@link ChatMessage}>>
     */
    @PostMapping("/business/messageList")
    public Result<PageResponse<ChatMessage>> businessChannelsList(@RequestBody PageKeyWordsRequest pageKeyWordsRequest) {
        return ResultUtil.success(messagesServiceImpl.businessChannelsList(pageKeyWordsRequest));
    }


    /**
     * 全球信息搜索
     *
     * @param messageRequest 消息请求
     * @return {@link ResponseResult}
     */
    @PostMapping("/global")
    public Result<PageResponse<ChatMessage>> globalInfoSearch(@RequestBody MessageRequest messageRequest) {
        PageResponse<ChatMessage> globalInfoSearch = messagesServiceImpl.globalInfoSearch(messageRequest);
        return ResultUtil.success(globalInfoSearch);
    }


    ///**
    // * 数据列表
    // */
    //@GetMapping
    //public QueryResponsePageResult<Messages> queryByPage(RequestQueryListData query) {
    //    return messagesService.listMessagessByPage(query);
    //}
    //
    ///**
    // * 根据id查询信息
    // */
    //@GetMapping("{id}")
    //public QueryResponseObjectResult queryMessagesById(@PathVariable("id") Long id, @PathVariable("chatId") Long chatId) {
    //    return null;
    //}
    //
    //
    ///**
    // * 添加
    // */
    //@PostMapping
    //public ResponseResult addMessages(@RequestBody Messages info) {
    //    return messagesService.addMessages(info);
    //}
    //
    ///**
    // * 根据id修改
    // */
    //@PutMapping("{id}")
    //public ResponseResult updateMessagesById(@PathVariable("id") Long id, @PathVariable("chatId") Long chatId, @RequestBody Messages info) {
    //    info.setId(id);
    //    info.setChatId(chatId);
    //    return messagesService.updateMessagesById(info);
    //}
    //
    //
    ///**
    // * 根据id删除
    // */
    //@DeleteMapping("{id}")
    //public ResponseResult deleteMessagesById(@PathVariable("id") Long id, @PathVariable("chatId") Long chatId) {
    //    return null;
    //}

}